﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using ApuestasJMG;
using System.Data;
using log4net;


namespace ApuestasJMG
{
    public class Global : System.Web.HttpApplication
    {
      
        private static readonly ILog log = LogManager.GetLogger(
         System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
       
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
          //System.IO.FileInfo loggerConfig = new System.IO.FileInfo("log4net.xml");
           
         //if (!loggerConfig.Exists)
           //
              //  MessageBox.Show("There is no log configurator file", "Attention");
            //
       //   log4net.Config.XmlConfigurator.Configure(loggerConfig);
            if (log.IsErrorEnabled)
            {
                log.Error("Page Load fallido.  ");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Aplicacion cargada correctamente.");
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Aplicacion iniciada.  ");
            }

            if (log.IsWarnEnabled)
            {
                log.Warn("Inicio de la aplicacion  ");
            }
        
        }


      void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown
    //      System.IO.FileInfo loggerConfig = new System.IO.FileInfo("log4net.xml");

      //    if (!loggerConfig.Exists)
        //  {
                //  MessageBox.Show("There is no log configurator file", "Attention");
          //}
           //og4net.Config.XmlConfigurator.Configure(loggerConfig);
            if (log.IsErrorEnabled)
            {
                log.Error("Page Load failed.  ");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Application loaded successfully.");
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Aplicacion terminada  ");
            }

            if (log.IsWarnEnabled)
            {
                log.Warn("Warning.  ");
            }
        
        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
   //       System.IO.FileInfo loggerConfig = new System.IO.FileInfo("log4net.xml");

    //      if (!loggerConfig.Exists)
      //    {
                //  MessageBox.Show("There is no log configurator file", "Attention");
          //}
        //  log4net.Config.XmlConfigurator.Configure(loggerConfig);
            if (log.IsErrorEnabled)
            {
                log.Error("Page Load failed.  ");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Application loaded successfully.");
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Error en la aplicacion  ");
            }

            if (log.IsWarnEnabled)
            {
                log.Warn("Warning.  ");
            }
        
        }

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
      //    System.IO.FileInfo loggerConfig = new System.IO.FileInfo("log4net.xml");

        //  if (!loggerConfig.Exists)
          //{
                //  MessageBox.Show("There is no log configurator file", "Attention");
            //
            //g4net.Config.XmlConfigurator.Configure(loggerConfig);
            if (log.IsErrorEnabled)
            {
                log.Error("Page Load failed.  ");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Application loaded successfully.");
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Sesion iniciada  ");
            }

            if (log.IsWarnEnabled)
            {
                log.Warn("Warning.  ");
            }
        
        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.
   //       System.IO.FileInfo loggerConfig = new System.IO.FileInfo("log4net.xml");

     //     if (!loggerConfig.Exists)
       //   {
                //  MessageBox.Show("There is no log configurator file", "Attention");
         // }
           //og4net.Config.XmlConfigurator.Configure(loggerConfig);
            if (log.IsErrorEnabled)
            {
                log.Error("Page Load failed.  ");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("Application loaded successfully.");
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Sesion terminada  ");
            }

            if (log.IsWarnEnabled)
            {
                log.Warn("Warning.  ");
            }
        
        }

    }
}

